package com.wuwei.elearning.question.domain;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
import java.util.Objects;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * <p>
 * 保存题目信息的表，不管是机型题，基础执照题，还是英语题，都保存在该表中
 * </p>
 *
 * @author wuwei
 * @since 2024-01-20
 */
@ApiModel(value = "Question对象", description = "保存题目信息的表，不管是机型题，基础执照题，还是英语题，都保存在该表中")
@Data
public class Question implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    @ExcelIgnore
    private Long id;

    @ApiModelProperty("题目所属的模块，如M1,M2，或者DA42全程班，DA42TEA补差AE等等")
    @ExcelProperty("模块")
    private String subject;

    @ApiModelProperty("题目所属的章节，如ATA32起落架系统，如M3液压系统，M5发动机进气道等等")
    @ExcelProperty("章节")
    private String chapter;

    @ApiModelProperty("题目所属的子章节，如机型题目的ATA32 起落架系统的收放系统，M3导航系统的无线电导航等等")
    @ExcelProperty("子章节")
    private String subChapter;

    @ApiModelProperty("题目的问题")
    @ExcelProperty("问题")
    private String question;

    @ApiModelProperty("选项1")
    @ExcelProperty("选项1")
    private String item1;

    @ApiModelProperty("选项2")
    @ExcelProperty("选项2")
    private String item2;

    @ApiModelProperty("选项3")
    @ExcelProperty("选项3")
    private String item3;

    @ApiModelProperty("选项4")
    @ExcelProperty("选项4")
    private String item4;

    @ApiModelProperty("正确答案，如果单选题则为A或者B或者C，如果多选题则为A+B+D,按照字母顺序排序 ")
    @ExcelProperty("正确答案")
    private String answer;

    @ExcelProperty("解析")
    @ApiModelProperty("备注")
    private String remark;

    // 检查是否属性完全相同（除了id）
    public boolean isSameAsNoM9(Question other) {
        return
                this.question.equals(other.question) &&
                this.item1.equals(other.item1) &&
                this.item2.equals(other.item2) &&
                this.item3.equals(other.item3) &&
                this.item4.equals(other.item4) &&
                this.answer.equals(other.answer)&&
                (this.remark!=null&&other.remark!=null&&this.remark.equals(other.remark));

    }

    // 检查是否属性完全相同（除了id）
    public boolean isSameAsM9(Question other) {
        return
                this.question.equals(other.question) &&
                this.item1.equals(other.item1) &&
                this.item2.equals(other.item2) &&
                this.item3.equals(other.item3) &&
                this.answer.equals(other.answer);

    }

//
//    @Override
//    public boolean equals(Object o) {
//        if (this == o) return true;
//        if (o == null || getClass() != o.getClass()) return false;
//        Question question = (Question) o;
//        return Objects.equals(subject, question.subject) &&
//                Objects.equals(chapter, question.chapter) &&
//                Objects.equals(subChapter, question.subChapter) &&
//                Objects.equals(this.question, question.question) &&
//                Objects.equals(item1, question.item1) &&
//                Objects.equals(item2, question.item2) &&
//                Objects.equals(item3, question.item3) &&
//                Objects.equals(item4, question.item4) &&
//                Objects.equals(answer, question.answer) &&
//                Objects.equals(remark, question.remark);
//    }
//
//    @Override
//    public int hashCode() {
//        return Objects.hash(subject, chapter, subChapter, question, item1, item2, item3, item4, answer, remark);
//    }



    @Override
    public String toString() {
        return "Question{" +
        "id=" + id +
        ", subject=" + subject +
        ", chapter=" + chapter +
        ", subChapter=" + subChapter +
        ", question=" + question +
        ", item1=" + item1 +
        ", item2=" + item2 +
        ", item3=" + item3 +
        ", item4=" + item4 +
        ", answer=" + answer +
        ", remark=" + remark +
        "}";
    }
}
